import { Module } from "@nestjs/common";
import { PassportModule } from "@nestjs/passport";
import { UserService } from "./user.service";
import { UserController } from "./user.controller";
import { Connection } from "typeorm";
import { CONSTANTS } from "../../ShareModule/constants/common.constants";

const UserProvider = [{
    provide: CONSTANTS.userRepository,
    useFactory: async (connection: Connection) => connection.getRepository('token'),
    inject: [CONSTANTS.typeormToken]
}]

@Module({
    imports: [PassportModule.register({ defaultStrategy: 'jwt' }),],
    controllers: [UserController],
    providers: [
        ...UserProvider, UserService
    ],
    exports: [UserService]
})
export class UserModule { }